package br.com.chat.server;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import br.com.chat.Message;
import br.com.chat.User;

public class MessageBox implements Serializable {

    private static final long serialVersionUID = 1L;

    private User owner;
    private List<Message> unreadMessages;

    public MessageBox(User owner) {
        super();
        this.owner = owner;
    }

    public User getOwner() {
        return owner;
    }

    public List<Message> getUnreadMessages() {
        if (unreadMessages == null) {
            unreadMessages = new ArrayList<Message>();
        }

        return unreadMessages;
    }

    public void clearMessages() {
        unreadMessages = null;
    }

    public void addMessage(Message message) {
        getUnreadMessages().add(message);
    }
}
